misc: cleanup requires inside checks - v1#2938
Conversation
- Move require expressions in shell check to requires object - Error if an unknown key is provided in a shell check
- Move require expressions in filter check to requires object - Error if an unknown key is provided in a filter check
|
Build against Suricata |
| gt-version: 8.0.4 | ||
| requires: | ||
| lt-version: 8.0.4 | ||
| gt-version: 8.0.4 |
There was a problem hiding this comment.
This looks like an impossible condition, however not new with this PR.
There was a problem hiding this comment.
I think @jufajardini did this for check to run on 7 and on main, but not on 8
There was a problem hiding this comment.
Otherwise check_filter_test_version_compat should be updated to catch more impossible cases
There was a problem hiding this comment.
Oh, but now the code did not check the gt-version at the root because it missed
@@ -551,12 +554,15 @@ class FilterCheck:
req_version = self.config.get("version")
min_version = self.config.get("min-version")
lt_version = self.config.get("lt-version")
+ gt_version = self.config.get("gt-version")
if req_version is not None:
requires["version"] = req_version
if min_version is not None:
requires["min-version"] = min_version
if lt_version is not None:
requires["lt-version"] = lt_version
+ if gt_version is not None:
+ requires["gt-version"] = gt_version
check_filter_test_version_compat(requires, self.test_version)
feature = self.config.get("feature")
if feature is not None:There was a problem hiding this comment.
Oh, but now the code did not check the gt-version at the root because it missed
@@ -551,12 +554,15 @@ class FilterCheck: req_version = self.config.get("version") min_version = self.config.get("min-version") lt_version = self.config.get("lt-version") + gt_version = self.config.get("gt-version") if req_version is not None: requires["version"] = req_version if min_version is not None: requires["min-version"] = min_version if lt_version is not None: requires["lt-version"] = lt_version + if gt_version is not None: + requires["gt-version"] = gt_version check_filter_test_version_compat(requires, self.test_version) feature = self.config.get("feature") if feature is not None:
Does this PR need a fix?
There was a problem hiding this comment.
I think your PR is good and I see further improvements
catenacyber
left a comment
There was a problem hiding this comment.
I love this
We should even further and add some code like
diff --git a/run.py b/run.py
index ad8f3057..ffb11d51 100755
--- a/run.py
+++ b/run.py
@@ -339,6 +339,9 @@ def check_requires(requires, suricata_config: SuricataConfig, test_dir=None):
raise UnsatisfiedRequirementError(
"requires at least version {}".format(min_version))
elif key == "lt-version":
+ if "gt-version" in requires:
+ raise UnnecessaryRequirementError(
+ "test has both lt-version {} and gt-version {}".format(requires["lt-version"], requires["gt-version"]))
lt_version = requires["lt-version"]
if not is_version_compatible(version=lt_version,
suri_version=suri_version, expr="lt"):
Follwup pr perhaps. Seems to be a separate concern. |
|
Merged in #2949, thanks! |
Filters that prevent a check from running should be inside a requires block as
this is what is documented in the README.